package com.lyhengtongwl.zqsnews.adapter;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lyhengtongwl.zqsnews.App;
import com.lyhengtongwl.zqsnews.R;
import com.lyhengtongwl.zqsnews.entity.NewsNoticeEntity;
import com.lyhengtongwl.zqsnews.utils.UpClickCountUtils;
import com.lyhengtongwl.zqsnews.ui.activity.NewsWebCommonActivity;
import com.lyhengtongwl.zqsnews.utils.AppConfig;

import java.util.List;

public class NewsNoticeAdapter extends BaseQuickAdapter<NewsNoticeEntity, BaseViewHolder> {
    private Activity activity;

    public NewsNoticeAdapter(Activity activity, List<NewsNoticeEntity> newsList) {
        super(R.layout.item_notice, newsList);
        this.activity = activity;
    }


    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(BaseViewHolder helper, NewsNoticeEntity item) {
        ((TextView) helper.getView(R.id.tv_time)).setText(item.getTime());
        ((TextView) helper.getView(R.id.title)).setText(item.getTitle());
//        ((TextView) helper.getView(R.id.content)).setText(item.getContent());
        ((TextView) helper.getView(R.id.content)).setText(Html.fromHtml(item.getContent()));
        helper.getView(R.id.rel_logOut).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                UpClickCountUtils.getInstance(activity).upClick("msgContent","消息详情");
                activity.startActivity(new Intent(activity, NewsWebCommonActivity.class).putExtra("url", AppConfig.getInstance(App.getContext()).get("newUrl")+"?id="+item.getLinkUrl()));
            }
        });

    }
}
